/*
 * Digital Audio Mobile - A multi track studio for Windows Mobile
 * Copyright (C) 2008 David Olsson
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#if !defined(__DIALOG_H__)
#define __DIALOG_H__

#include <windows.h>

class Dialog {
public:
    enum CommandSet {CS_CLOSE, CS_OKCANCEL};
    enum CloseCommand {CC_OK, CC_CANCEL};

    Dialog(HINSTANCE hInstance, const TCHAR *caption, CommandSet cs) throw();
    virtual ~Dialog() {}

    CloseCommand open() throw();

    unsigned int width() const throw();
    unsigned int height() const throw();

    HMENU enableMenu(const TCHAR *title) throw();

    HINSTANCE hInstance() throw();
    HWND hWnd() throw();
    HWND hMenuBar() throw();
    HMENU hMenu() throw();

    static unsigned int widthToPixels(unsigned int width) throw();
    static unsigned int heightToPixels(unsigned int height) throw();
    static unsigned int widthToDialogUnits(unsigned int width) throw();
    static unsigned int heightToDialogUnits(unsigned int height) throw();
protected:
    virtual bool close(CloseCommand cc) throw() = 0;
    virtual void controlNotification(HWND hWnd, WPARAM notification) throw() = 0;
    virtual void menuNotification(unsigned int itemId) throw() = 0;
private:
    static LRESULT CALLBACK wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

    HINSTANCE m_hInstance;
    HWND m_hWnd;
    HWND m_hWndMb;
    HMENU m_hMenu;
    CommandSet m_cs;
    bool m_close;
    CloseCommand m_cc;

    static const TCHAR * const CLASSNAME;
};

#endif
